import { GameMapItemType } from './../../../game/GameDefine';
import GameBagModel from "../../../game/model/GameBagModel";
import OrientationWidget from '../../OrientationWidget';

const {ccclass, property, menu} = cc._decorator;

@ccclass
@menu("Widget/Game/GameRoleInfoWidget")
export default class GameRoleInfoWidget extends OrientationWidget {
    @property(cc.Label)
    lb_key1_ptl: cc.Label = null;
    @property(cc.Label)
    lb_key2_ptl: cc.Label = null;

    @property(cc.Label)
    lb_key1_lsp: cc.Label = null;
    @property(cc.Label)
    lb_key2_lsp: cc.Label = null;
    
    public init(): void {
        this.updateBag();
    }

    public updateBag(){
        this.lb_key1_ptl.string = "" + GameBagModel.getInstance().data.keys[GameMapItemType.KEY_1];
        this.lb_key2_ptl.string = "" + GameBagModel.getInstance().data.keys[GameMapItemType.KEY_2];
        this.lb_key1_lsp.string = "" + GameBagModel.getInstance().data.keys[GameMapItemType.KEY_1];
        this.lb_key2_lsp.string = "" + GameBagModel.getInstance().data.keys[GameMapItemType.KEY_2];
    }

    protected onCanvasSizeChanged(): void {
        if(cc.view.getVisibleSize().width > cc.view.getVisibleSize().height){
            //横
            this.node.children.forEach(node=>{
                node.active = node.name.indexOf("_lsp") != -1;
                node.active = node.name.indexOf("_ptl") == -1;
            });
        }else{
            //竖
            this.node.children.forEach(node=>{
                node.active = node.name.indexOf("_lsp") == -1;
                node.active = node.name.indexOf("_ptl") != -1;
            });
        }
    }
}